<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div></div>
    <script>
        // 事件对象
        var div = document.querySelector('div');
        div.onclick = function(event) {
            console.log(event);
        }

        // 注册方式监听事件 (该方式的注册监听事件方法在IE9之后才支持 也有版本兼容的问题)
        div.addEventListener('click',function(e) {
            console.log(e);
        });

        //解决兼容的问题
        div.onclick = function(e) {
            e = e || window.event;
            console.log(e);
        }
    </script>
</body>
</html>